package com.huike.web.controller.report;


import com.huike.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.huike.common.core.domain.AjaxResult;
import com.huike.report.domain.vo.IndexVo;
import com.huike.report.service.IReportService;
import com.huike.report.service.IndexService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@Slf4j
@RequestMapping("/index")
public class IndexController {


    @Autowired
    private IndexService indexService;

    @Autowired
    private IReportService IReportService;


    @GetMapping()
    public AjaxResult queryData(
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate beginCreateTime,
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endCreateTime) {
        log.info("查询基础数据{}{}", beginCreateTime, endCreateTime);
        IndexVo queryData = indexService.getQueryData(beginCreateTime, endCreateTime);
        return AjaxResult.success(queryData);
    }


    /**
     * 线索转化龙虎榜接口
     *
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/salesStatistic")
    public AjaxResult salesStatistic(@RequestParam String beginCreateTime,
                                     @RequestParam String endCreateTime,
                                     @RequestParam(required = false) Long deptId) {
        //http://localhost:8080/index/salesStatistic?beginCreateTime=2023-09-09&endCreateTime=2023-10-09&deptId=100
        //1 接受参数
        log.info("线索转化龙虎榜接口:{},{},{}", beginCreateTime, endCreateTime, deptId);
        //3 响应数据
        return AjaxResult.success(IReportService.salesStatistic(beginCreateTime, endCreateTime, deptId));
    }
    /**
     * 商机转换龙虎榜接口
     *
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */

    @GetMapping("/businessChangeStatistics")
    public AjaxResult businessChangeStatistics(@RequestParam String beginCreateTime,
                                               @RequestParam String endCreateTime,
                                               @RequestParam(required = false) Long deptId) {
        //http://localhost:8080/index/businessChangeStatistics?beginCreateTime=2023-09-09&endCreateTime=2023-10-09&deptId=100
        //1 接受参数
        log.info("商机转化龙虎榜接口:{},{},{}", beginCreateTime, endCreateTime,deptId);
        //3 响应数据
        return AjaxResult.success(IReportService.businessChangeStatistics(beginCreateTime,endCreateTime,deptId));
    }





}